import math


class Circle:
    def __init__(self, radius, x=0, y=0):
        self.radius = radius
        self.x = x
        self.y = y

    def area(self):
        return math.pi * self.radius ** 2

    def circumference(self):
        return 2 * math.pi * self.radius

    # def __str__(self):
    #     return f"圆(半径={self.radius}, 圆心=({self.x}, {self.y}))"
    def show(self):
        print(f"这个圆的半径是{self.radius},坐标是x={self.x},y={self.y}")
#球类继承了圆类
class Ball(Circle):
    def __init__(self,radius,x=0,y=0,z=0,color="Black"):
        super().__init__(radius,x,y)#父类的初始化方法
        self.z=z
        self.color=color
        print("球初始化完成！")
    #重写父类的方法area
    def area(self):
        return 4*math.pi*self.radius**2
    def show(self):
        print(f"这个球的半径是{self.radius},坐标是{self.x},{self.y},{self.z},颜色是{self.color}")
    def volume(self):
        return 4/3*math.pi*self.radius**3
if __name__ == "__main__":
    b=Ball(10,0,0,0,"Gray")
    b.show()
    print(f"面积是：{b.area()}")
    print(f"周长是：{b.circumference()}")
    print(f"体积是{b.volume()}")
    # circle1 = Circle(5)
    # circle2 = Circle(3, 2, 4)
    #
    # print(f"{circle1}")
    # print(f"面积: {circle1.area():.2f}, 周长: {circle1.circumference():.2f}")
    #
    # print(f"\n{circle2}")
    # print(f"面积: {circle2.area():.2f}, 周长: {circle2.circumference():.2f}")
